package com.phx.serialjni;

import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Rect;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PageS {
    static int pageno ;
    static int pageback ;
    public  static boolean isActive = true;

    static  int pwidth = 1024;
    static  int pheight = 600;
    // static  int pwidth = 2191;
    // static  int pheight = 1080;
    static Integer[] nodeArray;
//       static String[][]  sliderCmd ={{"C1B00001", "C2B00002", "C3B00003", "C4B00004", "C5B00005", "C6B00006", "C7B00007", "C8B00008", "C9B00009", "CB0000A",},///////滑動調光
//            {"72B00009", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E",},
//            {"73B00009", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E",},
//            {"74B00009", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E",}};

    static String[][]  sliderCmd ={
            {"D1B00001", "D1B00002", "D1B00003", "D1B00004", "D1B00005", "D1B00006", "D1B00007", "D1B00008", "D1B00009", "D1B0000A",},///////滑動調光
            {"EE050001", "EE050002", "EE050003", "EE050004", "EE050005", "EE050006", "EE050007", "EE050008", "EE050009", "EE05000A",},
            {"EE060001", "EE060002", "EE060003", "EE060004", "EE060005", "EE060006", "EE060007", "EE060008", "EE060009", "EE06000A",},
            {"74B00009", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E", "C1E00009", "7161000E", "B161000E",}};


    static String[] allDArray = new String[]{"d001", "f002", "d002", "f001","f00d", "f006", "f004","f005",
            "1010","1011","71b0","72b0","73b0","b009","b00a","c001","c002","c003","c004","0ee2","0ee3",
            "0ee4","0ee5","0ee6","0ee7","0ee8","0eea","0eeb","c901","c902","c903","c904","7001",
            "7002","7003","7004","7005","7006","0ee1","0ee9",
            "b001","b002","b003","b004","b005","b006","b007","b008","b00b",
    "6001","6002"};
    //0EE2
//0EE3
//0EE4
//0EE5
//0EE6
//00
//0EE7
//0EEA
//0EEB
    // "f00d", "f006","b009" ,"f004","b00a"
    static String[] voladdress = {"1010","1011","6001","6002"};
    Integer[] resArray ;
    Integer[] seqArray ;
    static Integer[] offArray ;

    static Integer[] onArray ;

    static String[] cmdArray  ;
    static  Integer[] typeArray;
    static String[] feedDArray;

    int mleft = 1204;
    int mtop = 600;
    int mwidth = 144;
    int mheight = 145;
    static int jmpPosition = 0;
    static Rect[]  allRect;
    static Rect[]  allRects;
    public  static HashMap<String, String> feedMap = new HashMap<String, String>();
    public  static HashMap<String, String> feedType = new HashMap<String, String>();
    public int getCountx() {
        return seqArray.length;
    }
    public static String[] tmpAlla = new String[]{"d001", "f002", "d002", "f001","c001","c002",
            "c003","c004","f00d", "f006", "f004","b009","b00a",
            "1010","1011","71b0","72b0","73b0",
            "0ee2","0ee3","0ee4",
            "0ee5","0ee6",
            "0ee7","0ee8","0eea","0eeb","c901","c902","c903","c904","7001",
            "7002","7003","7004","7005","7006","0ee1","0ee9",
    "b001","b002","b003","b004","b005","b006","b007","b008","b00b"};
    //"f00d", "f006","b009" ,"f004","b00a"
//"0ee2","0ee3","0ee4","0ee5","0ee6","0ee7","0eea","0eeb"
 //   "f006", "f004","b009" ,"f00d","b00a"
  //  "0ee4", "0ee3", "0ee7", "0ee2","0ee8","0eeb","0eea"
    public static void setfeeds() {
        //  String[] feedDArrayx = new String[]{"d001", "f002", "d002", "f003",
        //          "f00d", "f006", "f004","f005",
        ////          "1010","1011","71b0","72b0","73b0","b009","b00a"};
        String[] feedDTypex = new String[]  {"1", "1", "1", "1", "1","1",
                "1","1","1","1","1","1","1",
                "2","2","6","6","6",
                "1","1","1",
                "9","9",
                "1","1","1","1",
        "1","1","1","1","1",
                "1","1","1","1","1","1","1",
                "1","1","1","1","1","1","1","1","1"};

        if(feedMap.isEmpty()) setfeedinit(tmpAlla,feedDTypex);

    }
//    static Integer[]  thumbx ={{"C1B00001", "C1B00002", "C1B00003", "C1B00004", "C1B00005",
//            "C1B00006", "C1B00007", "C1B00008", "C1B00009", "C1B00009"};
//    static Integer[]  thumby ={{"C1B00001", "C1B00002", "C1B00003", "C1B00004", "C1B00005",
//            "C1B00006", "C1B00007", "C1B00008", "C1B00009", "C1B00009"};

    public static Integer[]  uarrowax = new Integer[]{272,275, 278, 282, 286, 290, 294, 298, 302, 305,
            309, 312, 316, 319, 323, 326, 329, 333, 336, 340, 343,347, 350, 354, 357, 360};
    public static Integer[]  uarroway = new Integer[]{357, 357, 357, 356, 356, 356, 356, 355, 355, 355,
            354, 354, 354, 353 ,353, 353, 353, 352, 352, 352,351, 351, 351, 350, 350};
    public static Integer[] uarrowam= new Integer[]{0,0};
//    public static Integer[] uarrowam= new Integer[]{R.drawable.e1, R.drawable.e2, R.drawable.e3,
//            R.drawable.e4, R.drawable.e5, R.drawable.e6, R.drawable.e7, R.drawable.e8, R.drawable.e9,
//            R.drawable.e10, R.drawable.e11,R.drawable.e12, R.drawable.e13, R.drawable.e14, R.drawable.e15,
//            R.drawable.e16, R.drawable.e17, R.drawable.e18, R.drawable.e19,R.drawable.e20,R.drawable.e21,
//            R.drawable.e82, R.drawable.e83, R.drawable.e84, R.drawable.e85,R.drawable.e86};
    public static Integer[]  uarrowbx = new Integer[]{734, 737, 740, 742, 745, 748, 751, 754, 756, 759,
            762, 765, 767, 770, 772, 775, 778, 780, 783, 785, 788,791, 794, 796, 799, 802};
    public static Integer[]  uarrowby =  new Integer[]{327, 327, 326, 326, 326, 326, 325, 325, 325, 325,
            324, 324, 324, 324, 324, 323, 323, 323, 323, 323, 323,323, 322, 322, 321, 321};
    public static Integer[] uarrowbm= new Integer[]{0,0};
//    public static Integer[] uarrowbm= new Integer[]{R.drawable.e22, R.drawable.e23,
//            R.drawable.e24, R.drawable.e25, R.drawable.e26, R.drawable.e27,
//            R.drawable.e28, R.drawable.e29,R.drawable.e30, R.drawable.e31,R.drawable.e32, R.drawable.e33,
//            R.drawable.e34, R.drawable.e35, R.drawable.e36, R.drawable.e37, R.drawable.e38, R.drawable.e39,
//            R.drawable.e40,R.drawable.e41,R.drawable.e42, R.drawable.e93,
//            R.drawable.e94, R.drawable.e95, R.drawable.e96,R.drawable.e97};
    // String[] thumbs =

    public static boolean ifValue()
    {
        if(feedMap == null) {

            return false;
        }
        return  true;
    }

    public static void setfeedinit(String[] myDArrayx,String[] myDArray)
    {
        int vv = myDArrayx.length;
        for (int x=0; x<vv; x++) {
            if(!myDArrayx[x].equals("")) {
                feedMap.put(myDArrayx[x],"0000");
                feedType.put(myDArrayx[x],myDArray[x]);
            }
        }
    }

    public void s0() {
        pageno = 0;
        pageback = R.drawable.a1;
        jmpPosition = 0;
        seqArray = new Integer[]{1, 2, 3, 4, 5, 6,7,8,9,10,11,12};
        typeArray = new Integer[]{20, 20, 20, 20,19, 19, 19, 19, 19, 19,19,19};
        cmdArray = new String[]{"0","1","2","3","D1E00000","F2100000", "D2E00000", "F1100000",
            "C9010000", "C9020000", "C9030000", "C9040000",
        };/////燈光頁面調節
        nodeArray = new Integer[]{1, 1, 1,1, 0, 0, 0, 0, 0, 0,0,0};
        feedDArray = new String[]{"", "", "", "","d001", "f002", "d002", "f001","c901","c902","c903","c904"};
        offArray = new Integer[]{R.drawable.b1_off, R.drawable.b2_off, R.drawable.b3_off };
        allRect = new Rect[12];
        allRect[0] = new Rect(204, 482, 204 + 105, 482 + 105);
        allRect[1] = new Rect(375, 482, 375 + 105, 482 + 105);
        allRect[2] = new Rect(549, 482, 549 + 105, 482 + 105);
        allRect[3] = new Rect(716, 482, 716 + 105, 482 + 105);
        allRect[4] = new Rect(241, 68, 241 + 91, 68 + 91);
        allRect[5] = new Rect(391, 68, 391 + 91, 68 + 91);
        allRect[6] = new Rect(541, 68, 541 + 91, 68 + 91);
        allRect[7] = new Rect(691, 68, 691  + 91, 68 + 91);
        allRect[8] = new Rect(359, 278, 359 + 100, 278 + 23);
        allRect[9] = new Rect(463, 278, 463 + 100, 278 + 23);
        allRect[10] = new Rect(567, 278, 567  + 100, 278 + 23);
        allRect[11] = new Rect(671, 278, 671 + 100, 278 + 23);
    }
    public void s1() {
        pageno = 1;
        pageback = R.drawable.a2;
        jmpPosition = 1;
        seqArray = new Integer[]{1, 2, 3,4};
        cmdArray = new String[]{"0","1","2","3"};
        feedDArray = new String[]{"", "", "",""};
        nodeArray = new Integer[]{1, 1, 1,1};
        typeArray = new Integer[]{20, 20, 20,20}; //20 19 16 16 command 25 not
        offArray = new Integer[]{R.drawable.c1_off, R.drawable.c2_off, R.drawable.c3_off,R.drawable.c4_off};
        onArray = new Integer[]{R.drawable.c1_on, R.drawable.c2_on, R.drawable.c3_on,R.drawable.c4_on };
        allRect = new Rect[4];
        allRect[0] = new Rect(204, 482, 204 + 105, 482 + 105);
        allRect[1] = new Rect(375, 482, 375 + 105, 482 + 105);
        allRect[2] = new Rect(549, 482, 549 + 105, 482 + 105);
        allRect[3] = new Rect(716, 482, 716 + 105, 482 + 105);
    }
    public void s2() {
        pageno = 2;
        pageback = R.drawable.a3;
        jmpPosition = 2;
        seqArray = new Integer[]{1, 2, 3, 4, 5, 6,7,8};
        cmdArray = new String[]{"0","1","2","3",
                "F6100000","F4100000" ,"FD100000","BB100000"
        };
        feedDArray = new String[]{"", "", "","" ,"f006", "f004" ,"f00d","b00b"};
        nodeArray = new Integer[]{1, 1, 1,1, 0,0,0,0};
        typeArray = new Integer[]{20, 20, 20,20, 19, 19,19,19};
        offArray = new Integer[]{R.drawable.c1_off, R.drawable.c2_off, R.drawable.c3_off,R.drawable.c4_off,
                R.drawable.c1_off, R.drawable.c2_off, R.drawable.c4_off, R.drawable.c5_off};
        onArray = new Integer[]{R.drawable.c1_on, R.drawable.c2_on, R.drawable.c3_on,R.drawable.c4_on,
                R.drawable.c1_on, R.drawable.c2_on,R.drawable.c4_on, R.drawable.c5_on};
        allRect = null;
        allRect = new Rect[8];
        allRect[0] = new Rect(204, 482, 204 + 105, 482 + 105);
        allRect[1] = new Rect(375, 482, 375 + 105, 482 + 105);
        allRect[2] = new Rect(549, 482, 549 + 105, 482 + 105);
        allRect[3] = new Rect(716, 482, 716 + 105, 482 + 105);
        allRect[4] = new Rect(207, 192, 207 + 92, 192 + 92);
        allRect[5] = new Rect(377, 192, 377 + 92, 192 + 92);
        //  allRect[5] = new Rect(272, 278, 272 + 92, 278 + 92);
        allRect[6] = new Rect(551, 192, 551 + 92, 192 + 92);
        allRect[7] = new Rect(724, 192, 724 + 92, 192 + 92);
    }
    public void s3() {
        pageno = 3;
        pageback = R.drawable.a4;
        jmpPosition = 3;
        seqArray = new Integer[]{1, 2, 3, 4, 5, 6,7,8,9,10};
        typeArray = new Integer[]{20, 20, 20, 20,19, 19, 19, 19, 19,19};
       cmdArray = new String[]{"0","1","2","3","EE040000","EE030000", "EE020000",
                "EE080000", "EE0B0000", "EE0A0000"
        };/////燈光頁面調節

        nodeArray = new Integer[]{1, 1, 1, 1,0, 0, 0, 0, 0,0};
       feedDArray = new String[]{"", "", "","", "ffff", "ffff", "0ee2","0ee8","ffff","ffff"};
        offArray = new Integer[]{R.drawable.b1_off, R.drawable.b2_off, R.drawable.b3_off,
              };

        onArray = new Integer[]{R.drawable.b1_on, R.drawable.b2_on, R.drawable.b3_on,};
        allRect = new Rect[10];
        allRect[0] = new Rect(204, 482, 204 + 105, 482 + 105);
        allRect[1] = new Rect(375, 482, 375 + 105, 482 + 105);
        allRect[2] = new Rect(549, 482, 549 + 105, 482 + 105);
        allRect[3] = new Rect(716, 482, 716 + 105, 482 + 105);

        allRect[4] = new Rect(215, 118, 215 + 63, 118 + 63);
        allRect[5] = new Rect(567, 118, 567 + 63, 118 + 63);
        allRect[6] = new Rect(746, 118, 746  + 63, 118 + 63);
        allRect[7] = new Rect(746, 301, 746 + 63, 301 + 63);
        allRect[8] = new Rect(215, 301, 215 + 63, 301 + 63);
        allRect[9] = new Rect(567, 301, 567  + 63, 301 + 63);
    }
    public void setInit(int currentPage) {
        switch (currentPage) {
            case 0:
                s0();
                break;
            case 1:
                s1();
                break;
            case  2:
                s2();
                break;
            case  3:
                s3();
                break;
            default:
                break;
        }
    }
}

